package controllers

import (
	"github.com/astaxie/beego"
)

type ApiBaseController struct {
	beego.Controller
}

var HOST = "http://hxp.guangfen.net/"
var GUANG_FEN_HOST = "http://open.guangfen.net/api/v46/"

type BaseBean struct {
	Code    string `json:"code"`
	Message string `json:"msg"`
}

const (
	appKey = "1aed92c7e715a86bc36da554"
	secret = "304c1e8bdd840a2101f992f8"
)

var APP_SECRET = "aSVUpejcaMjPqPBRoUykYZxSulIyIOlZ"

func (this *ApiBaseController) Prepare() {
	this.Ctx.Output.Header("Access-Control-Allow-Method", "POST")
	this.Ctx.Output.Header("Access-Control-Allow-Method", "GET")
	this.Ctx.Output.Header("Access-Control-Allow-Method", "DELETE")
	this.Ctx.Output.Header("Access-Control-Allow-Method", "PUT")
	this.Ctx.Output.Header("Access-Control-Allow-Method", "OPTIONS")
	this.Ctx.Output.Header("Access-Control-Allow-Origin", "*")
}

type ReturnData struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
}

type TableCodeData struct {
	TableCode   string `json:"table_code"`
	LinkAddress string `json:"link_address"`
	DeviceId	string `json:"device_id"`
}

type TradeBeanResult struct {
	ReturnData
	Data    TradeBean `json:"data,omitempty"`
	PayInfo PayInfo   `json:"pay_info,omitempty"`
}

type PayOrderQueryResult struct {
	ReturnData
	Data TradeBean `json:"data"`
}

type DeviceAuthBean struct {
	StoreCode string `json:"store_code"`
	DeviceId  string `json:"device_id"`
	RegId     string `json:"reg_id"`
}

type H5ResultBean struct {
	Code      string `json:"code"`
	Msg       string `json:"msg"`
	TimeStamp string `json:"timestamp"`
	Version     string `json:"version"`
	Sign        string `json:"sign"`
	TradeNo     string `json:"trade_no"`
	TradeStatus string `json:"trade_status"`
	PayChannel  string `json:"pay_channel"`
	TotalAmount string `json:"total_amount"`
	BuyerId     string `json:"buyer_id"`
	StoreCode   string `json:"store_code"`
	DevId       string `json:"dev_id"`
	DownTradeNo string `json:"down_trade_no"`
	UpTradeNo   string `json:"up_trade_no"`
	RawData     string `json:"raw_data"`
	OperId      string `json:"oper_id"`
	TimeEnd     string `json:"time_end"`
}

type TradeBean struct {
	TradeNo          string `json:"trade_no"`
	TradeStatus      string `json:"trade_status"`
	PayType          string `json:"pay_type"`
	PayChannel       string `json:"pay_channel"`
	TotalAmount      int    `json:"total_amount"`
	SellerAmount     int    `json:"seller_amount"`
	SellerCoupon     int    `json:"seller_coupon"`
	BuyerAmount      int    `json:"buyer_amount"`
	CurrentAmount    int    `json:"current_amount"`
	ChnCoupon        int    `json:"chn_coupon"`
	UndiscountAmount int    `json:"undiscount_amount"`
	BuyerId          string `json:"buyer_id"`
	StoreName        string `json:"store_name"`
	StoreCode        string `json:"store_code"`
	DevId            string `json:"dev_id"`
	DownTradeNo      string `json:"down_trade_no"`
	UpTradeNo        string `json:"up_trade_no"`
	RawData          string `json:"raw_data"`
	OperId           string `json:"oper_id"`
	Subject          string `json:"subject"`
	TimeEnd          string `json:"time_end"`
	RefundTime       string `json:"refund_time"`
	CodeUrl          string `json:"code_url"`
	PrepayId         string `json:"prepay_id"`
}

type PayInfo struct {
	AppId     string `json:"app_id"`
	NonceStr  string `json:"nonce_str"`
	Package   string `json:"package"`
	PaySign   string `json:"pay_sign"`
	SignType  string `json:"sign_type"`
	TimeStamp string `json:"time_stamp"`
}

type OrderResultBean struct {
	PayInfo   PayInfo `json:"pay_info"`
	UpTradeNo string  `json:"up_trade_no"`
	TradeNo   string  `json:"trade_no"`
}

type QueryOrderBean struct {
	TradeNo       string `json:"trade_no"`
	UpTradeNo     string `json:"up_trade_no"`
	DownTradeNo   string `json:"down_trade_no"`
	StoreCode     string `json:"store_code"`
	TableCode     string `json:"table_code"`
	StoreName     string `json:"store_name"`
	TradeStatus   string `json:"trade_status"`
	TradeChannel  string `json:"trade_channel"`
	PayAmount     int    `json:"pay_amount,omitempty"`
	ReceiptAmount int    `json:"receipt_amount,omitempty"`
	BuyerAmount   int    `json:"buyer_amount,omitempty"`
	BuyerUserId   string `json:"buyer_user_id,omitempty"`
	BuyerUserName string `json:"buyer_user_name,omitempty"`
	OpenId        string `json:"opend_id,omitempty"`
	SubOpenId     string `json:"sub_opend_id,omitempty"`
	RawData       string `json:"raw_data,omitempty"`
	CreateTime    string `json:"create_time,omitempty"`
	PayTime       string `json:"pay_time,omitempty"`
}

type SendHookBean struct {
	Version   string `json:"version,omitempty"`    //版本号
	SignType  string `json:"sign_type,omitempty"`  //签名方式
	RequestId string `json:"request_id,omitempty"` //推送唯一码
	TimeStamp string `json:"time_stamp,omitempty"` //当前时间
	Sign      string `json:"sign,omitempty"`       //签名值
	//业务模块
	TradeNo           string `json:"trade_no,omitempty"`
	DownTradeNo       string `json:"down_trade_no,omitempty"`
	PayChannelTradeNo string `json:"pay_channel_trade_no,omitempty"`
	TradeStatus       string `json:"trade_status,omitempty"`
	TradeChannel      string `json:"trade_channel,omitempty"`
	PayAmount         int    `json:"pay_amount,omitempty"`
	ReceiptAmount     int    `json:"receipt_amount,omitempty"`
	BuyerAmount       int    `json:"buyer_amount,omitempty"`
	BuyerUserId       string `json:"buyer_user_id,omitempty"`
	BuyerUserName     string `json:"buyer_user_name,omitempty"`
	OpenId            string `json:"opend_id,omitempty"`
	SubOpenId         string `json:"sub_opend_id,omitempty"`
	StoreCode         string `json:"store_code,omitempty"`
	RawData           string `json:"raw_data,omitempty"`
	CreateTime        string `json:"create_time,omitempty"`
	PayTime           string `json:"pay_time,omitempty"`
}

type DeviceBindBean struct {
	StoreCode string `json:"store_code"`
	DeviceId  string `json:"device_id"`
	TableCode string `json:"table_code"`
}
